package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysCarLocation;
import com.ruoyi.system.service.ISysCarLocationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆位置表Controller
 * 
 * @author ruoyi
 * @date 2022-05-11
 */
@RestController
@RequestMapping("/system/location")
public class SysCarLocationController extends BaseController
{
    @Autowired
    private ISysCarLocationService sysCarLocationService;

    /**
     * 查询车辆位置表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysCarLocation sysCarLocation)
    {
        startPage();
        List<SysCarLocation> list = sysCarLocationService.selectSysCarLocationList(sysCarLocation);
        return getDataTable(list);
    }

    /**
     * 导出车辆位置表列表
     */
    @Log(title = "车辆位置表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCarLocation sysCarLocation)
    {
        List<SysCarLocation> list = sysCarLocationService.selectSysCarLocationList(sysCarLocation);
        ExcelUtil<SysCarLocation> util = new ExcelUtil<SysCarLocation>(SysCarLocation.class);
        util.exportExcel(response, list, "车辆位置表数据");
    }

    /**
     * 获取车辆位置表详细信息
     */
    @GetMapping(value = "/{locId}")
    public AjaxResult getInfo(@PathVariable("locId") Long locId)
    {
        return AjaxResult.success(sysCarLocationService.selectSysCarLocationByLocId(locId));
    }

    /**
     * 新增车辆位置表
     */
    @Log(title = "车辆位置表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysCarLocation sysCarLocation)
    {
        return toAjax(sysCarLocationService.insertSysCarLocation(sysCarLocation));
    }

    /**
     * 修改车辆位置表
     */
    @Log(title = "车辆位置表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysCarLocation sysCarLocation)
    {
        return toAjax(sysCarLocationService.updateSysCarLocation(sysCarLocation));
    }

    /**
     * 删除车辆位置表
     */
    @Log(title = "车辆位置表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{locIds}")
    public AjaxResult remove(@PathVariable Long[] locIds)
    {
        return toAjax(sysCarLocationService.deleteSysCarLocationByLocIds(locIds));
    }
}
